<?php
/**
 * Login Form
 *
 * @author Petr Laslo
 * @license MIT License
 * @package Knihovna\Forms
 * @link https://code.google.com/p/knihovna/
 */

class Knihovna_Form_Login extends Zend_Form
{
    /*
     * Inicializace formuláře
     *
     * @param void
     * @return void
     */
    public function init()
    {
        $this->setAction('/user/login');
        $this->setMethod(Zend_Form::METHOD_POST);
        $this->setAttrib('id', 'login_form');

        $userName     = new Zend_Form_Element_Text('user_name',
            array('size'     => 15,
                  'maxlength'=> 20,
                  'label'    => 'Uživatelské jméno',
                  'require'  => true));
        $userPassword = new Zend_Form_Element_Password('user_password', array('label'  => 'Heslo',
                                                                             'require'=> true));
        $send = new Zend_Form_Element_Submit('submit_login','Přihlásit');

        $userName->addValidator('NotEmpty',true);
        $userPassword->addValidator('NotEmpty',true);

        $userName->addValidator('StringLength', true, array(4, 64));
        $userPassword->addValidator('StringLength', true, array(5, 64));


        $userName->addFilter('StringTrim');
        $userName->addFilter('StripTags');
        $userPassword->addFilter('StringTrim');

        $this->addElements(array($userName, $userPassword, $send));
    }
}

